//
//  BulletIndicator.m
//  Project5
//
//  Created by Nguyen Tan Loc on 5/20/13.
//  Copyright (c) 2013 Nguyen Tan Loc. All rights reserved.
//

#import "BulletIndicator.h"

@implementation BulletIndicator

-(id) init
{
    if (self = [super init])
    {
        m_Sprite = [CCSprite spriteWithSpriteFrameName:@"plant7@2x.png"];
        [self addChild:m_Sprite];
        [m_Sprite setScale:0.2];
    }
    
    return self;
}

-(void) setStartPoint:(CGPoint)p
{
    m_StartPoint = p;
}

-(void) setEndPoint:(CGPoint)p
{
    m_Angle = atan2f(p.x - m_StartPoint.x, p.y - m_StartPoint.y) * 180.0f / kmPI;
    [m_Sprite setRotation:m_Angle];
}

-(void) removeIndicator
{
    // invisible sprite using fade
    m_StartPoint = ccp(0.0f, 0.0f);
}

-(float) getAngle
{
    return (90.0f - m_Angle);
}

@end
